home *** CD-ROM | disk | FTP | other *** search
/ Linux 68k 2000 / Linux 68k 2000.iso / dokus / NIS-HOWTO < prev    next >
Encoding:
Text File  |  1997-11-15  |  37.2 KB  |  934 lines

  1.   The Linux NIS(YP)/NYS/NIS+ HOWTO
  2.   Thorsten Kukuk
  3.   v0.8, 9 November 1997
  4.  
  5.   This document describes how to configure Linux as NIS(YP) or NIS+
  6.   client and how to install as NIS server.
  7.  
  8.   1.  Introduction
  9.  
  10.   More and more, Linux machines are installed as part of a network of
  11.   computers. To simplify network administration, most networks (mostly
  12.   Sun-based networks) run the Network Information Service. Linux
  13.   machines can take full advantage of existing NIS service or provide
  14.   NIS service themselves. Linux machines can also act as full NIS+
  15.   clients, this support is in beta stage.
  16.  
  17.   This document tries to answer questions about setting up NIS(YP) and
  18.   NIS+ on your Linux machine. Don't forget to read the section about
  19.   ``the RPC Portmapper''
  20.  
  21.   The NIS-Howto is edited and maintained by:
  22.  
  23.        Thorsten Kukuk, kukuk@vt.uni-paderborn.de
  24.  
  25.   The primary source of the information for the initial NIS-Howto was
  26.   from:
  27.  
  28.        Andrea Dell'Amico       <adellam@ZIA.ms.it>
  29.        Mitchum DSouza          <Mitch.DSouza@NetComm.IE>
  30.        Erwin Embsen            <erwin@nioz.nl>
  31.        Peter Eriksson          <peter@ifm.liu.se>
  32.  
  33.   who we should thank for writing the first versions of this document.
  34.  
  35.   1.1.  New versions of this document
  36.  
  37.   New versions of this document will be posted periodically to the
  38.   newsgroups  comp.os.linux.help <news:comp.os.linux.help> and
  39.   comp.osl.linux.announce <news:comp.os.linux.announce>.  They will also
  40.   be uploaded to various Linux WWW and FTP sites, including the LDP home
  41.   page.
  42.  
  43.   You can always view the latest version of this on the World Wide Web
  44.   via the URL http://sunsite.unc.edu/mdw/HOWTO/NIS-HOWTO.html
  45.   <http://sunsite.unc.edu/mdw/HOWTO/NIS-HOWTO.html>.
  46.  
  47.   1.2.  Disclaimer
  48.  
  49.   Although this document has been put together to the best of our
  50.   knowledge it may, and probably does contain errors. Please read any
  51.   README files that are bundled with any of the various pieces of
  52.   software described in this document for more detailed and accurate
  53.   information. We will attempt to keep this document as error free as
  54.   possible.
  55.  
  56.   1.3.  Feedback and Corrections
  57.  
  58.   If you have questions or comments about this document, please feel
  59.   free to mail Thorsten Kukuk, at kukuk@vt.uni-paderborn.de. I welcome
  60.   any suggestions or criticisms. If you find a mistake with this
  61.   document, please let me know so I can correct it in the next version.
  62.   Thanks.
  63.  
  64.   Please do not mail me questions about special problems with your Linux
  65.   distributions! I don't know every Linux Distribution. But I will try
  66.   to add every solution you send me.
  67.  
  68.   1.4.  Acknowledgements
  69.  
  70.   We would like to thank all the people who have contributed (directly
  71.   or indirectly) to this document. In alphabetical order:
  72.  
  73.        Byron A Jeff            <byron@cc.gatech.edu>
  74.        Miquel van Smoorenburg  <miquels@cistron.nl>
  75.  
  76.   Theo de Raadt <deraadt@theos.com> is responsible for the original yp-
  77.   clients code.  Swen Thuemmler <swen@uni-paderborn.de> ported the yp-
  78.   clients code to Linux and also ported the yp-routines in libc (again
  79.   based on Theo's work). Thorsten Kukuk has written the NIS(YP) and NIS+
  80.   routines for GNU libc 2.x from scratch.
  81.  
  82.   2.  Glossary and General Information
  83.  
  84.   2.1.  Glossary of Terms
  85.  
  86.   In this document a lot of acronyms are used. Here are the most
  87.   important acronyms and a brief explanation:
  88.  
  89.      DBM
  90.         DataBase Management, a library of functions which maintain key-
  91.         content pairs in a data base.
  92.  
  93.      DLL
  94.         Dynamically Linked Library, a library linked to an executable
  95.         program at run-time.
  96.  
  97.      domainname
  98.         A name "key" that is used by NIS clients to be able to locate a
  99.         suitable NIS server that serves that domainname key. Please note
  100.         that this does not necessarily have anything at all to do with
  101.         the DNS "domain" (machine name) of the machine(s).
  102.  
  103.      FTP
  104.         File Transfer Protocol, a protocol used to transfer files
  105.         between two computers.
  106.  
  107.      libnsl
  108.         Name services library, a library of name service calls
  109.         (getpwnam, getservbyname, etc...) on SVR4 Unixes. GNU libc uses
  110.         this for the NIS (YP) and NIS+ functions.
  111.  
  112.      libsocket
  113.         Socket services library, a library for the socket service calls
  114.         (socket, bind, listen, etc...) on SVR4 Unixes.
  115.  
  116.      NIS
  117.         Network Information Service, a service that provides
  118.         information, that has to be known throughout the network, to all
  119.         machines on the network. There is support for NIS in Linux's
  120.         standard libc library, which in the following text is referred
  121.         to as "traditional NIS".
  122.  
  123.      NIS+
  124.         Network Information Service (Plus :-), essentially NIS on
  125.         steroids. NIS+ is designed by Sun Microsystems Inc. as a
  126.         replacement for NIS with better security and better handling of
  127.         _large_ installations.
  128.  
  129.      NYS
  130.         This is the name of a project and stands for NIS+, YP and Switch
  131.         and is managed by Peter Eriksson <peter@ifm.liu.se>. It contains
  132.         among other things a complete reimplementation of the NIS (= YP)
  133.         code that uses the Name Services Switch functionality of the NYS
  134.         library.
  135.  
  136.      NSS
  137.         Name Service Switch. The /etc/nsswitch.conf file determines the
  138.         order of lookups performed when a certain piece of information
  139.         is requested.
  140.  
  141.      RPC
  142.         Remote Procedure Call. RPC routines allow C programs to make
  143.         procedure calls on other machines across the network.  When
  144.         people talk about RPC they most often mean the Sun RPC variant.
  145.  
  146.      YP Yellow Pages(tm), a registered trademark in the UK of British
  147.         Telecom plc.
  148.  
  149.      TCP-IP
  150.         Transmission Control Protocol/Internet Protocol. It's the data
  151.         communication protocol most often used on Unix machines.
  152.  
  153.   2.2.  Some General Information
  154.  
  155.   The next four lines are quoted from the Sun(tm) System & Network
  156.   Administration Manual:
  157.  
  158.            "NIS was formerly known as Sun Yellow Pages (YP) but
  159.             the name Yellow Pages(tm) is a registered trademark
  160.             in the United Kingdom of British Telecom plc and may
  161.             not be used without permission."
  162.  
  163.   NIS stands for Network Information Service. It's purpose is to provide
  164.   information, that has to be known throughout the network, to all
  165.   machines on the network. Information likely to be distributed by NIS
  166.   is:
  167.  
  168.   ╖  login names/passwords/home directories (/etc/passwd)
  169.  
  170.   ╖  group information (/etc/group)
  171.  
  172.   So, for example, if your password entry is recorded in the NIS passwd
  173.   database, you will be able to login on all machines on the net which
  174.   have the NIS client programs running.
  175.  
  176.   Sun is a trademark of Sun Microsystems, Inc. licensed to SunSoft, Inc.
  177.  
  178.   3.  NIS or NIS+ ?
  179.  
  180.   The choice between NIS and NIS+ is easy - use NIS if you don't have to
  181.   use NIS+ or have severe security needs. NIS+ is _much_ more
  182.   problematic to administer (it's pretty easy to handle on the client
  183.   side, but the server side is horrible). Another proble is that the
  184.   support for NIS+ under Linux is still under developement - you need
  185.   the latest glibc snapshot for it or have to wait for glibc 2.1. There
  186.   is a port of the glibc NIS+ support for libc5 as drop in replacement.
  187.  
  188.   3.1.  libc 4/5 with traditional NIS or NYS ?
  189.  
  190.   The choice between "traditional NIS" or the NIS code in the NYS
  191.   library is a choice between laziness and maturity vs. flexibility and
  192.   love of adventure.
  193.  
  194.   The "traditional NIS" code is in the standard C library and has been
  195.   around longer and sometimes suffers from it's age and slight
  196.   inflexibility.
  197.  
  198.   The NIS code in the NYS library requires you to recompile the libc
  199.   library to include the NYS code into the libc library (or maybe you
  200.   can go get a precompiled version of libc from someone who has already
  201.   done it).
  202.  
  203.   Another difference is that the traditional NIS code has some support
  204.   for NIS Netgroups, which the NYS code doesn't (yet). On the other hand
  205.   the NYS code allows you to handle Shadow Passwords in a transparent
  206.   way. The "traditonal NIS" code doesn't support Shadow Passwords over
  207.   NIS.
  208.  
  209.   Forgot this all if you use the new GNU C Library 2.x (aka libc6). It
  210.   supports NSS (name switch service), which makes it very flexible, and
  211.   contains support for the following NIS/NIS+ maps: aliases, ethers,
  212.   group, hosts, netgroups, networks, protocols, publickey, passwd, rpc,
  213.   services and shadow.
  214.  
  215.   4.  How it works
  216.  
  217.   4.1.  How NIS(YP) works
  218.  
  219.   Within a network there must be at least one machine acting as a NIS
  220.   server. You can have multiple NIS servers, each serving different NIS
  221.   "domains" - or you can have cooperating NIS servers, where one is said
  222.   to be the master NIS server, and all the other are so-called slave NIS
  223.   servers (for a certain NIS "domain", that is!) - or you can have a mix
  224.   of them...
  225.  
  226.   Slave servers only have copies of the NIS databases and receive these
  227.   copies from the master NIS server whenever changes are made to the
  228.   master's databases.  Depending on the number of machines in your
  229.   network and the reliability of your network, you might decide to
  230.   install one or more slave servers.  Whenever a NIS server goes down or
  231.   is too slow in responding to requests, a NIS client connected to that
  232.   server will try to find one that is up or quicker.
  233.  
  234.   NIS databases are in so-called DBM format, derived from ASCII
  235.   databases.  For example, the files /etc/passwd and /etc/group can be
  236.   directly converted to DBM format using ASCII-to-DBM translation
  237.   software ("makedbm", it's included with the server software). The
  238.   master NIS server should have both, the ASCII databases and the DBM
  239.   databases.
  240.  
  241.   Slave servers  will be notified of any change to the NIS maps, (via
  242.   the "yppush" program), and automatically retrieve the necessary
  243.   changes in order to synchronize their databases. NIS clients do not
  244.   need to do this since they always talks to the NIS server to read the
  245.   information stored in it's DBM databases.
  246.  
  247.   The author of the YP clients for linux has informed us that the newest
  248.   ypbind (ypbind-3.3.tar.gz) is able to get the server from a
  249.   configuration file - thus no need to broadcast (which is insecure -
  250.   due to the fact that anyone may install a NIS server and answer the
  251.   broadcast queries...)
  252.  
  253.   4.2.  How NIS+ works
  254.  
  255.   NIS+ is a new version of the network information nameservice from Sun.
  256.   The biggest difference between NIS and NIS+ is, that NIS+ has support
  257.   for data encryption and authentication over secure RPC.
  258.  
  259.   The  naming  model of NIS+ is based upon a tree structure. Each node
  260.   in the tree corresponds to an NIS+ object, from which we have six
  261.   types: directory, entry, group, link, table and private.
  262.  
  263.   The NIS+ directory that forms the root of the NIS+ namespace is called
  264.   the root directory. There are two special NIS+ directories: org_dir
  265.   and groups_dir. The org_dir directory consists of all administration
  266.   tables, such as passwd, hosts, and mail_aliases. The groups_dir
  267.   directory consists of NIS+ group objects which are used for access
  268.   control. The collection of org_dir, groups_dir and their parent
  269.   directory is referred to as an NIS+ domain.
  270.  
  271.   5.  The RPC Portmapper
  272.  
  273.   To run any of the software mentioned below you will need to run the
  274.   program /usr/sbin/portmap. Some Linux distributions already have the
  275.   code in the /etc/rc.d/ files to start up this daemon.  All you have to
  276.   do is to activate it and reboot your Linux machine.  Read your Linux
  277.   Distribution Documentation how to do this.
  278.  
  279.   The RPC portmapper (portmap(8)) is a server that converts RPC program
  280.   numbers into TCP/IP (or UDP/IP) protocol port numbers. It must be
  281.   running in order to make RPC calls (which is what the NIS/NIS+ client
  282.   software does) to RPC servers (like a NIS or NIS+ server) on that
  283.   machine.  When an RPC server is started, it will tell portmap what
  284.   port number it is listening to, and what RPC program numbers it is
  285.   prepared to serve.  When a client wishes to make an RPC call to a
  286.   given program number, it will first contact portmap on the server
  287.   machine to determine the port number where RPC packets should be sent.
  288.   Normally, standard RPC servers are started by inetd(8), so portmap
  289.   must be started before inetd is invoked.
  290.  
  291.   For secure RPC, the portmapper needs the Time Service. Make sure, that
  292.   the Time Service is enabled in /etc/inetd.conf on all hosts:
  293.  
  294.        #
  295.        # Time service is used for clock syncronization.
  296.        #
  297.        time    stream  tcp     nowait  nobody  /usr/sbin/tcpd  in.timed
  298.        time    dgram   udp     wait    nobody  /usr/sbin/tcpd  in.timed
  299.  
  300.   IMPORTANT: Don't forget to restart inetd after changes on this file !
  301.  
  302.   6.  What do you need to set up NIS?
  303.  
  304.   6.1.  Determine whether you are a Server, Slave or Client.
  305.  
  306.   To answer this question you have to consider two cases:
  307.  
  308.   1. Your machine is going to be part of a network with existing NIS
  309.      servers
  310.  
  311.   2. You do not have any NIS servers in the network yet
  312.  
  313.   In the first case, you only need the client programs (ypbind, ypwhich,
  314.   ypcat, yppoll, ypmatch). The most important program is ypbind. This
  315.   program must be running at all times, that is, it should always appear
  316.   in the list of processes. It's a so-called daemon process and needs to
  317.   be started from the system's startup file (eg. /etc/rc.local,
  318.   /etc/init.d/nis, /etc/rc.d/init.d/ypbind).  As soon as ypbind is
  319.   running, your system has become a NIS client.
  320.  
  321.   In the second case, if you don't have NIS servers, then you will also
  322.   need a NIS server program (usually called ypserv). Section 8 describes
  323.   how to set up a NIS server on your Linux machine using the "ypserv"
  324.   implementation by Peter Eriksson and Thorsten Kukuk.  Note that from
  325.   version 0.14 this implementation supports the master-slave concept
  326.   talked about in section 4.1.
  327.  
  328.   There is also another free NIS server available, called "yps", written
  329.   by Tobias Reber in Germany which does support the master-slave
  330.   concept, but has other limitations and isn't supported any longer.
  331.  
  332.   6.2.  The Software
  333.  
  334.   The system library "/usr/lib/libc.a" (version 4.4.2 and better) or the
  335.   shared library "/lib/libc.so.x" contain all necessary system calls to
  336.   succesfully compile the NIS client and server software. For glibc 2.x,
  337.   you also need /lib/libnsl.so.1.
  338.  
  339.   Some people reported that NIS only works with "/usr/lib/libc.a"
  340.   version 4.5.21 and better so if you want to play it safe don't use
  341.   older libc's.  The NIS client software can be obtained from:
  342.  
  343.     Site                  Directory                        File Name
  344.  
  345.     ftp.uni-paderborn.de  /linux/local/yp                  yp-clients-2.2.tar.gz
  346.     ftp.uni-paderborn.de  /linux/local/yp                  ypbind-3.3.tar.gz
  347.     wauug.erols.com       /pub/net/nis                     yp-tools-1.2.tar.gz
  348.     wauug.erols.com       /pub/net/nis                     ypbind-3.3.tar.gz
  349.     ftp.lysator.liu.se    /pub/NYS/clients                 yp-tools-1.2.tar.gz
  350.     sunsite.unc.edu       /pub/Linux/system/Network/admin  yp-clients-2.2.tar.gz
  351.  
  352.   Once you obtained the software, please follow the instructions which
  353.   come with the software. yp-clients 2.2 are for use with libc4 and
  354.   libc5 until 5.4.20. libc 5.4.21 and glibc 2.x needs yp-tools 1.2.
  355.   ypbind 3.3 will work with all libraries. You should never use the
  356.   ypbind from yp-clients 2.2.
  357.  
  358.   6.3.  The ypbind daemon
  359.  
  360.   Assuming you have succesfully compiled the software you are now ready
  361.   to install the software. A suitable place for the ypbind daemon is the
  362.   directory /usr/sbin. Some people may tell you, that you don't need
  363.   ypbind on a system with NYS. This is wrong, ypwhich and ypcat need it.
  364.  
  365.   You'll need to do this as root of course. The other binaries (ypwhich,
  366.   ypcat, yppoll, ypmatch) should go in a directory accessible by all
  367.   users, normally /usr/bin.
  368.  
  369.   The ypbind process has a configuration file called /etc/yp.conf. You
  370.   can hardcode a NIS server there - for more info see the manual page
  371.   for ypbind(8).  You also need this file for NYS.  An example:
  372.  
  373.          ypserver voyager
  374.          ypserver ds9
  375.  
  376.   If the system could resolv the hostnames without NIS, you could use
  377.   the name, else you have to use the IP address.
  378.  
  379.   It might be a good idea to test ypbind before  incorporating it in the
  380.   /etc/rc.d/ files. To test ypbind do the following:
  381.  
  382.   ╖  Make sure you have your domain name set. If it is not set then
  383.      issue the command:
  384.  
  385.                    /bin/domainname nis.domain
  386.  
  387.   where nis.domain should be some string, _NOT_ normally associated with
  388.   the domain name of your machine! The reason for this is that it makes
  389.   it a little harder for external crackers to retreive the password
  390.   database from your NIS servers. If you don't know what the NIS domain
  391.   name is on your network, ask your system/network administrator.
  392.   ╖  Start up "/usr/sbin/portmap" if it is not already running.
  393.  
  394.   ╖  Create the directory "/var/yp" if it does not exist.
  395.  
  396.   ╖  Start up "/usr/sbin/ypbind"
  397.  
  398.   ╖  Use the command "rpcinfo -p localhost" to check if ypbind was able
  399.      to register its service with the portmapper. The rpcinfo should
  400.      produce something like:
  401.  
  402.               program vers proto   port
  403.                100000    2   tcp    111  portmapper
  404.                100000    2   udp    111  portmapper
  405.                100007    2   udp    637  ypbind
  406.                100007    2   tcp    639  ypbind
  407.                300019    1   udp    660
  408.  
  409.   ╖  You may also run "rpcinfo -u localhost ypbind". This command should
  410.      produce something like:
  411.  
  412.                program 100007 version 2 ready and waiting
  413.  
  414.   At this point you should be able to use NIS client programs like
  415.   ypcat, etc...  For example, "ypcat passwd" will give you the entire
  416.   NIS password database.
  417.  
  418.   IMPORTANT: If you skipped the test procedure then make sure you have
  419.   set the domain name, and created the directory:
  420.  
  421.            /var/yp
  422.  
  423.   This directory MUST exist for ypbind to start up succesfully.
  424.  
  425.   If the test worked you may now want to change the files in /etc/rc.d/
  426.   on your system so that ypbind will be started up at boot time and your
  427.   system will act as a NIS client. Make sure, that the domainname will
  428.   be set at boot time.
  429.  
  430.   Well, that's it. Reboot the machine and watch the boot messages to see
  431.   if ypbind is actually started.
  432.  
  433.   6.4.  Setting up a NIS Client using Traditional NIS
  434.  
  435.   For host lookups you must set (or add) "nis" to the lookup order line
  436.   in your /etc/host.conf file. Please read the manpage "resolv+.8" for
  437.   more details.
  438.  
  439.   Add the following line to /etc/passwd on your NIS clients:
  440.  
  441.        +::::::
  442.  
  443.   You can also use the + and - characters to include/exclude or change
  444.   users. If you want to exclude the user guest just add -guest to your
  445.   /etc/passwd file.  You want to use a different shell (e.g. ksh) for
  446.   the user "linux"?  No problem, just add "+linux::::::/bin/ksh"
  447.   (without the quotes) to your /etc/passwd. Fields that you don't want
  448.   to change have to be left empty. You could also use Netgroups for user
  449.   control.
  450.  
  451.   For example, to only allow login-access to miquels, dth and ed, and
  452.   all members of the sysadmin netgroup, but to have the account data of
  453.   all other users available:
  454.  
  455.              +miquels:::::::
  456.              +ed:::::::
  457.              +dth:::::::
  458.              +@sysadmins:::::::
  459.              -ftp
  460.              +:*::::::/etc/NoShell
  461.  
  462.   Note that in Linux you can also override the password field, as we did
  463.   in this example. In this exaample, we also remove the login "ftp", so
  464.   it isn't known any longer, and anonymous ftp will not work.
  465.  
  466.   The netgroup would be look like
  467.  
  468.        sysadmins (-,software,) (-,kukuk,)
  469.  
  470.   IMPORTANT: Note that the netgroup  feature is implemented starting
  471.   from libc 4.5.26. But if you have a version of libc earlier than
  472.   4.5.26, every user in the NIS password database can access your linux
  473.   machine if you run "ypbind".
  474.  
  475.   6.5.  Setting up a NIS Client using NYS
  476.  
  477.   All that is required is that the NIS configuration file (/etc/yp.conf)
  478.   points to the correct server(s) for its information.  Also, the Name
  479.   Services Switch configuration file (/etc/nsswitch.conf) must be
  480.   correctly set up.
  481.  
  482.   You should install ypbind. It isn't needed by the libc, but the
  483.   NIS(YP) tools need it.
  484.  
  485.   If you wish to use the inclucde/exclude user feature
  486.   (+/-guest/+@admins), you have to use "passwd: compat" and "group:
  487.   compat". Note, that there is no "shadow: compat" ! You have to use
  488.   "shadow: files nis" in this case.
  489.  
  490.   6.6.  Setting up a NIS Client using glibc 2.x
  491.  
  492.   The glibc uses "traditional NIS", so you need to start ypbind. The
  493.   Name Services Switch configuration file (/etc/nsswitch.conf) must be
  494.   correctly set up. If you use the compat mode for passwd, shadow or
  495.   group, you have to add the "+" at the end of this files, and you could
  496.   use the include/exclude user feature. The configuration is excatly thw
  497.   same as under Solaris 2.x.
  498.  
  499.   6.7.  The nsswitch.conf File
  500.  
  501.   The Network Services switch file /etc/nsswitch.conf determines the
  502.   order of lookups performed when a certain piece of information is
  503.   requested, just like the /etc/host.conf file which determines the way
  504.   host lookups are performed. For example, the line
  505.  
  506.            hosts: files nis dns
  507.  
  508.   specifies that host lookup functions should first look in the local
  509.   /etc/hosts file, followed by a NIS lookup and finally thru the domain
  510.   name service (/etc/resolv.conf and named), at which point if no match
  511.   is found an error is returned.
  512.  
  513.   A good /etc/nsswitch.file for NISis:
  514.  
  515.   #
  516.   # /etc/nsswitch.conf
  517.   #
  518.   # An example Name Service Switch config file. This file should be
  519.   # sorted with the most-used services at the beginning.
  520.   #
  521.   # The entry '[NOTFOUND=return]' means that the search for an
  522.   # entry should stop if the search in the previous entry turned
  523.   # up nothing. Note that if the search failed due to some other reason
  524.   # (like no NIS server responding) then the search continues with the
  525.   # next entry.
  526.   #
  527.   # Legal entries are:
  528.   #
  529.   #       nisplus                 Use NIS+ (NIS version 3)
  530.   #       nis                     Use NIS (NIS version 2), also called YP
  531.   #       dns                     Use DNS (Domain Name Service)
  532.   #       files                   Use the local files
  533.   #       db                      Use the /var/db databases
  534.   #       [NOTFOUND=return]       Stop searching if not found so far
  535.   #
  536.  
  537.   passwd:     compat
  538.   group:      compat
  539.   shadow:     compat
  540.  
  541.   passwd_compat: nis
  542.   group_compat: nis
  543.   shadow_compat: nis
  544.  
  545.   hosts:      nis files dns
  546.  
  547.   services:   nis [NOTFOUND=return] files
  548.   networks:   nis [NOTFOUND=return] files
  549.   protocols:  nis [NOTFOUND=return] files
  550.   rpc:        nis [NOTFOUND=return] files
  551.   ethers:     nis [NOTFOUND=return] files
  552.   netmasks:   nis [NOTFOUND=return] files
  553.   netgroup:   nis
  554.   bootparams: nis [NOTFOUND=return] files
  555.   publickey:  nis [NOTFOUND=return] files
  556.   automount:  files
  557.   aliases:    nis [NOTFOUND=return] files
  558.  
  559.   passwd_compat, group_compat and shadow_compat are only supported by
  560.   glibc 2.x.  If there are no shadow rules in /etc/nsswitch.conf, glibc
  561.   will use the passwd rule for lookups. There are some more lookup
  562.   module for glibc like hesoid.  For more information, read the glibc
  563.   documentation.
  564.  
  565.   7.  What do you need to set up NIS+ ?
  566.  
  567.   7.1.  The Software
  568.  
  569.   You need to retrieve and compile the latest GNU C library 2 snapshot.
  570.   And you need a glibc based system like RedHat Mustang or the unstable
  571.   Debian. But be warned: This are all beta Software ! Read the Docs
  572.   about glibc snapshots and from the Distributions ! glibc 2.0.x doesn't
  573.   contain the NIS+ support, and will never contain it. The first public
  574.   version with NIS+ support will be 2.1.
  575.  
  576.   The NIS+ client software can be obtained from:
  577.  
  578.          Site                   Directory                  File Name
  579.  
  580.          ftp.kernel.org         /pub/software/libs/glibc   libc-*, glibc-crypt-*,
  581.                                                            glibc-linuxthreads-*,
  582.                                                            glibc-localedata-*
  583.          wauug.erols.com        /pub/net/nis               nis-tools-1.4.tar.gz
  584.          wauug.erols.com        /pub/net/nis               pam_keylogin-1.0.tar.gz
  585.  
  586.   Distributions based on glibc can be fetched from:
  587.  
  588.          Site                   Directory
  589.  
  590.          ftp.redhat.com         /pub/redaht/mustang
  591.          ftp.debian.org         /pub/debian/hamm
  592.  
  593.   For compilation of the GNU C Library, please follow the instructions
  594.   which come with the software. There is a patched libc5, based on NYS
  595.   and the glibc sources. ad drop in replacement for the standart libc5.
  596.  
  597.   You should also look at http://www-vt.uni-
  598.   paderborn.de/~kukuk/linux/nisplus.html <http://www-vt.uni-
  599.   paderborn.de/~kukuk/linux/nisplus.html> for more information and the
  600.   latest sources.
  601.  
  602.   7.2.  Setting up a NIS+ client
  603.  
  604.   IMPORTANT: For setting up a NIS+ client, read your Solaris NIS+ docs
  605.   what to do on the server side ! This document only describes what to
  606.   do on the client side !
  607.  
  608.   After installing the new libc and nis-tools, run
  609.  
  610.        domainname nisplus.domain.
  611.        nisinit -c -H <NIS+ server>
  612.  
  613.   to initialize the cold Start File. Read the nisinit man page for more
  614.   options. Make sure, that the domainname will always be set after a
  615.   reboot.  If you don't knw what the NIS+ domain name is on your
  616.   network, ask your system/network administrator.
  617.  
  618.   Now you should change your /etc/nsswitch.conf file. Make sure, that
  619.   the only service after publickey is nisplus ("publickey: nisplus"),
  620.   and nothing else !
  621.  
  622.   After this, start keyserv and make sure, that it will always be
  623.   started at boot time. Run
  624.  
  625.        keylogin -r
  626.  
  627.   to store the root secretkey on your system. (I hope you have added the
  628.   publickey for the new host on the NIS+ Server ?).
  629.  
  630.   "niscat passwd.org_dir" should now show you all entries in the passwd
  631.   database.
  632.  
  633.   7.3.  NIS+, keylogin, login and PAM
  634.  
  635.   When the user logs in, he need to set his secretkey to keyserv. This
  636.   is done by calling "keylogin". The login from the shadow package will
  637.   do this for the user. For a PAM aware login, you have to install
  638.   pam_keylogin-1.0.tar.gz and change the /etc/pam.d/login file to use
  639.   pam_unix_auth, not pwdb, which doesn't support NIS+. An example:
  640.  
  641.        #%PAM-1.0
  642.        auth       required     /lib/security/pam_securetty.so
  643.        auth       required     /lib/security/pam_keylogin.so
  644.        auth       required     /lib/security/pam_unix_auth.so
  645.        auth       required     /lib/security/pam_nologin.so
  646.        account    required     /lib/security/pam_unix_acct.so
  647.        password   required     /lib/security/pam_unix_passwd.so
  648.        session    required     /lib/security/pam_unix_session.so
  649.  
  650.   7.4.  The nsswitch.conf.File
  651.  
  652.   The Network Services switch file /etc/nsswitch.conf determines the
  653.   order of lookups performed when a certain piece of information is
  654.   requested, just like the /etc/host.conf file which determines the way
  655.   host lookups are performed. For example, the line
  656.  
  657.            hosts: files nisplus dns
  658.  
  659.   specifies that host lookup functions should first look in the local
  660.   /etc/hosts file, followed by a NIS+ lookup and finally thru the domain
  661.   name service (/etc/resolv.conf and named), at which point if no match
  662.   is found an error is returned.
  663.  
  664.   A good /etc/nsswitch.file for NISis:
  665.  
  666.   #
  667.   # /etc/nsswitch.conf
  668.   #
  669.   # An example Name Service Switch config file. This file should be
  670.   # sorted with the most-used services at the beginning.
  671.   #
  672.   # The entry '[NOTFOUND=return]' means that the search for an
  673.   # entry should stop if the search in the previous entry turned
  674.   # up nothing. Note that if the search failed due to some other reason
  675.   # (like no NIS server responding) then the search continues with the
  676.   # next entry.
  677.   #
  678.   # Legal entries are:
  679.   #
  680.   #       nisplus                 Use NIS+ (NIS version 3)
  681.   #       nis                     Use NIS (NIS version 2), also called YP
  682.   #       dns                     Use DNS (Domain Name Service)
  683.   #       files                   Use the local files
  684.   #       db                      Use the /var/db databases
  685.   #       [NOTFOUND=return]       Stop searching if not found so far
  686.   #
  687.  
  688.   passwd:     compat
  689.   group:      compat
  690.   shadow:     compat
  691.  
  692.   passwd_compat: nisplus
  693.   group_compat:  nisplus
  694.   shadow_compat: nisplus
  695.  
  696.   hosts:      nisplus files dns
  697.  
  698.   services:   nisplus [NOTFOUND=return] files
  699.   networks:   nisplus [NOTFOUND=return] files
  700.   protocols:  nisplus [NOTFOUND=return] files
  701.   rpc:        nisplus [NOTFOUND=return] files
  702.   ethers:     nisplus [NOTFOUND=return] files
  703.   netmasks:   nisplus [NOTFOUND=return] files
  704.   netgroup:   nisplus
  705.   bootparams: nisplus [NOTFOUND=return] files
  706.   publickey:  nisplus
  707.   automount:  files
  708.   aliases:    nisplus [NOTFOUND=return] files
  709.  
  710.   8.  Setting up a NIS Server
  711.  
  712.   8.1.  The Server Program ypserv
  713.  
  714.   This document only describes how to set up the "ypserv" NIS server.
  715.  
  716.   The NIS server software can be found on:
  717.  
  718.          Site                   Directory                     File Name
  719.  
  720.          waaug.erols.com        /pub/net/nis                  ypserv-1.2.5.tar.gz
  721.          ftp.lysator.liu.se     /pub/NYS/servers              ypserv-1.2.5.tar.gz
  722.          ftp.uni-paderborn.de   /linux/local/yp               ypserv-1.2.5.tar.gz
  723.  
  724.   You could also look at http://www-vt.uni-
  725.   paderborn.de/~kukuk/linux/nis.html <http://www-vt.uni-
  726.   paderborn.de/~kukuk/linux/nis.html> for more information and the
  727.   latest sources.
  728.  
  729.   The server setup is the same for both traditional NIS and NYS.
  730.  
  731.   Compile the software to generate the "ypserv" and "makedbm" programs.
  732.   If you run your server as master, determine what files you require to
  733.   be available via NIS and then add or remove the appropriate entries to
  734.   the /var/yp/Makefile.
  735.  
  736.   Now edit /var/yp/securenets and /etc/ypserv.conf.  For more
  737.   information, read the ypserv(8) and ypserv.conf(5) manual pages.
  738.  
  739.   Make sure the portmapper (portmap(8)) is running, and start the server
  740.   "ypserv". The command
  741.  
  742.            % rpcinfo -u localhost ypserv
  743.  
  744.   should output something like
  745.  
  746.            program 100004 version 2 ready and waiting
  747.  
  748.   Now generate the NIS (YP) database. On the master, run
  749.  
  750.            % /usr/lib/yp/ypinit -m
  751.  
  752.   on a slave, make sure that ypwhich -m works. Then run
  753.  
  754.            % /usr/lib/yp/ypinit -s masterhost
  755.  
  756.   That's it, your server is up and running.
  757.  
  758.   You might want to edit root's crontab *on the slave* server and add
  759.   the following lines:
  760.  
  761.              20 *    * * *    /usr/lib/yp/ypxfr_1perhour
  762.              40 6    * * *    /usr/lib/yp/ypxfr_1perday
  763.              55 6,18 * * *    /usr/lib/yp/ypxfr_2perday
  764.  
  765.   This will ensure that most NIS maps are kept up-to-date, even if an
  766.   update is missed because the slave was down at the time the update was
  767.   done on the master.
  768.  
  769.   If you want to restrict access to your NIS server, you'll have to
  770.   setup the NIS server as a client as well by running ypbind and adding
  771.   the plus-entries to /etc/passwd _halfway_ the password file. The
  772.   library functions will ignore all normal entries after the first NIS
  773.   entry, and will get the rest of the info through NIS. This way the NIS
  774.   access rules are maintained. example:
  775.  
  776.             root:x:0:0:root:/root:/bin/bash
  777.             daemon:*:1:1:daemon:/usr/sbin:
  778.             bin:*:2:2:bin:/bin:
  779.             sys:*:3:3:sys:/dev:
  780.             sync:*:4:100:sync:/bin:/bin/sync
  781.             games:*:5:100:games:/usr/games:
  782.             man:*:6:100:man:/var/catman:
  783.             lp:*:7:7:lp:/var/spool/lpd:
  784.             mail:*:8:8:mail:/var/spool/mail:
  785.             news:*:9:9:news:/var/spool/news:
  786.             uucp:*:10:50:uucp:/var/spool/uucp:
  787.             nobody:*:65534:65534:noone at all,,,,:/dev/null:
  788.             +miquels::::::
  789.             +:*:::::/etc/NoShell
  790.             [ All normal users AFTER this line! ]
  791.             tester:*:299:10:Just a test account:/tmp:
  792.             miquels:1234567890123:101:10:Miquel van Smoorenburg:/home/miquels:/bin/zsh
  793.  
  794.   The user tester will exist, but have a shell of /etc/NoShell. miquels
  795.   will have normal access.
  796.  
  797.   Alternatively, you could edit the /var/yp/Makefile file and set NIS to
  798.   use another source password file. On big systems, the NIS password and
  799.   group files are usually stored in /var/yp/ypfiles/. If you do this the
  800.   normal tools to administrate the password file such as "passwd",
  801.   "chfn", "adduser" will not work anymore and you will need special
  802.   homemade tools for this.
  803.  
  804.   However yppasswd, ypchsh and ypchfn will work ofcourse.
  805.  
  806.   8.2.  The Server Program yps
  807.  
  808.   To set up the "yps" NIS server please refer to the previous paragraph.
  809.   The "yps" server setup is similar, _but_ not exactly the same so
  810.   beware if you try to apply the "ypserv" instructions to "yps"!  "yps"
  811.   is not supported by any author, and contains same security leaks.  You
  812.   shouldn't really use it !
  813.  
  814.   The "yps" NIS server software can be found on:
  815.  
  816.          Site                Directory                         File Name
  817.  
  818.          ftp.lysator.liu.se  /pub/NYS/servers                  yps-0.21.tar.gz
  819.          ftp.funet.fi        /pub/Linux/BETA/NYS/servers       yps-0.21.tar.gz
  820.  
  821.   8.3.  The Program rpc.yppasswdd
  822.  
  823.   Whenever users change their passwords, the NIS password database and
  824.   probably other NIS databases, which depend on the NIS password
  825.   database, should be updated.  The program "rpc.yppasswdd" is a server
  826.   that handles password changes and makes sure that the NIS information
  827.   will be updated accordingly. rpc.yppasswdd is now integrated in ypserv
  828.   1.2.5. You don't need the older, separate yppasswd-0.9.tar.gz or
  829.   yppasswd-0.10.tar.gz, and you shouldn't use them any longer. The
  830.   rpc.yppasswdd in ypserv 1.2.5 has full shadow support. yppasswd is now
  831.   part of yp-tools-1.2.tar.gz, ypserv-1.2.5.tar.gz contains the sources
  832.   for the same version.
  833.  
  834.   9.  Verifying the NIS/NYS Installation
  835.  
  836.   If everything is fine (as it should be), you should be able to verify
  837.   your installation with a few simple commands. Assuming, for example,
  838.   your passwd file is being supplied by NIS, the command
  839.  
  840.            % ypcat passwd
  841.  
  842.   should give you the contents of your NIS passwd file. The command
  843.  
  844.            % ypmatch userid passwd
  845.  
  846.   (where userid is the login name of an arbitrary user) should give you
  847.   the user's entry in the NIS passwd file. The "ypcat" and "ypmatch"
  848.   programs should be included with your distribution of traditional NIS
  849.   or NYS.
  850.  
  851.   If a user couldn't log in, run the following program on the client:
  852.  
  853.   #include <stdio.h>
  854.   #include <pwd.h>
  855.   #include <sys/types.h>
  856.  
  857.   int
  858.   main(int argc, char *argv[])
  859.   {
  860.     struct passwd *pwd;
  861.  
  862.     if(argc != 2)
  863.       {
  864.         fprintf(stderr,"Usage: getwpnam username\n");
  865.         exit(1);
  866.       }
  867.  
  868.     pwd=getpwnam(argv[1]);
  869.  
  870.     if(pwd != NULL)
  871.       {
  872.         printf("name.....: [%s]\n",pwd->pw_name);
  873.         printf("password.: [%s]\n",pwd->pw_passwd);
  874.         printf("user id..: [%d]\n", pwd->pw_uid);
  875.         printf("group id.: [%d]\n",pwd->pw_gid);
  876.         printf("gecos....: [%s]\n",pwd->pw_gecos);
  877.         printf("directory: [%s]\n",pwd->pw_dir);
  878.         printf("shell....: [%s]\n",pwd->pw_shell);
  879.       }
  880.     else
  881.       fprintf(stderr,"User \"%s\" not found!\n",argv[1]);
  882.  
  883.     exit(0);
  884.   }
  885.  
  886.   Running this program with the username as parameter, will print all
  887.   the information the getpwnam function will give back for this user.
  888.   This should show you, which entry is incorrect. The most common
  889.   problem is, that the password field is overwritten with a "*".
  890.  
  891.   10.  Common Problems and Troubleshooting NIS
  892.  
  893.   Here are some common problems reported by various users:
  894.  
  895.   1. The libraries for 4.5.19 are broken. NIS won't work with it.
  896.  
  897.   2. If you upgrade the libraries from 4.5.19 to 4.5.24 then the su
  898.      command breaks. You need to get the su command from the slackware
  899.      1.2.0 distribution. Incidentally that's where you can get the
  900.      updated libraries.
  901.  
  902.   3. You could run into trouble with NIS and DNS on the same machine.
  903.      My DNS server occasionally will not bring up NIS. Haven't yet
  904.      tracked down why.
  905.  
  906.   4. When a NIS server goes down and comes up again ypbind starts
  907.      complaining with messages like:
  908.  
  909.               yp_match: clnt_call:
  910.                           RPC: Unable to receive; errno = Connection refused
  911.  
  912.   and logins are refused for those who are registered in the NIS
  913.   database. Try to login as root and if you succeed, then kill ypbind
  914.   and start it up again.
  915.  
  916.   5. After upgrade the libc to a version greater then 5.4.20, the YP
  917.      tools will not work any longer. You need yp-tools 1.2 or later for
  918.      libc >= 5.4.21 and glibc 2.x and yp-clients 2.2. for earlier
  919.      versions.
  920.  
  921.   11.  Frequently Asked Questions
  922.  
  923.   Most of your questions should be answered by now. If there are still
  924.   questions unanswered you might want to post a message to
  925.  
  926.            comp.os.linux.help
  927.  
  928.   or
  929.  
  930.            comp.os.linux.networking
  931.  
  932.   or contact one of the authors of this HOWTO.
  933.  
  934.